home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5925 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.8 KB  |  72 lines

  1. Newsgroups: comp.lang.c++
  2. Path: BALROG.NCI.NIH.GOV!SYSTEX
  3. From: systex@BALROG.NCI.NIH.GOV (Donald G. Plugge, Systex Inc., (301)210-7701)
  4. Subject: VMS Descriptors in C++?
  5. Message-ID: <1996Feb7.143723.25305@alw.nih.gov>
  6. Sender: postman@alw.nih.gov (AMDS Postmaster)
  7. Nntp-Posting-Host: balrog.nci.nih.gov
  8. Reply-To: systex@BALROG.NCI.NIH.GOV
  9. Organization: Organization, City, State, etc.
  10. Date: Wed, 7 Feb 1996 14:37:23 GMT
  11.  
  12.  
  13.  
  14. In the spirit of object oriented programming, I'd like to ask a design question
  15. in order to determine which C++ component to utilize in a particular case.  I
  16. have experience with C, however, I have just begun to explore the vast
  17. assortment of features available in C++.  My questions concerns the string
  18. class and whether to include, cast or inherit them into another structure.
  19.  
  20. My coding is done on an Alpha 3400 running VMS 6.1 with DEC C++ version 3.1. 
  21. In the VMS environment system service calls use a structure called a descriptor
  22. to pass character data.  The definition of the structure is contained in the
  23. <descrip.h> file.  The relevant section follows below.  Notice that the code
  24. #defines a $DESCRIPTOR macro to place an array of characters into the
  25. descriptor structure.  The new descriptor is then ready to be passed to the
  26. system service.
  27.  
  28. /*
  29.  *    Fixed-Length Descriptor:
  30.  */
  31. struct    dsc$descriptor_s
  32. {
  33.     unsigned short    dsc$w_length;    /* length of data item in bytes,
  34.                          or if dsc$b_dtype is DSC$K_DTYPE_V, bits,
  35.                          or if dsc$b_dtype is DSC$K_DTYPE_P, digits (4 bits each) */
  36.     unsigned char    dsc$b_dtype;    /* data type code */
  37.     unsigned char    dsc$b_class;    /* descriptor class code = DSC$K_CLASS_S */
  38.     char        *dsc$a_pointer;    /* address of first byte of data storage */
  39. };
  40.  
  41.  
  42. /*
  43.  *    A simple macro to construct a string descriptor:
  44.  */
  45. #define $DESCRIPTOR(name,string)    struct dsc$descriptor_s name = { sizeof(string)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, string }
  46.  
  47. An example of a call to the macro would be:
  48.  
  49.     
  50.     dsc$descriptor_s dsc;
  51.     $DESCRIPTOR(dsc, "XYZ");
  52.     status = SYS$GETDVI (0, 0, &dsc, &itmlst[0], &iosb, 0, 0, 0);
  53.  
  54. The $DESCRIPTOR syntax only takes literal character array and not a Class
  55. strings.  If I create a subroutine to call the system service by passing a 
  56. literal character array, that works fine.  However, if I pass a string object,
  57. then the $DESCRIPTOR fails.
  58.  
  59. Would it be wise to create a descriptor class which is derived from a string
  60. class?  From what I've been reading in "Effective C++" by Meyers the derived
  61. class "isa" base class.  So, the derived descriptor should really be a string,
  62. but that doesn't seem to fit.  Perhaps the descriptor class should contain a
  63. member function which returns the proper descriptor.  Or perhaps I shouldn't
  64. use the DEC provided descrip.h at all and create a new structure based upon
  65. the string class.
  66.  
  67. Any thoughts about what is good and proper?
  68.  
  69.  
  70.                     Donald G. Plugge
  71.  
  72.